from socket import socket, AF_INET, SOCK_DGRAM
# 创建socket
server = socket(AF_INET, SOCK_DGRAM)
# 指定接收方的IP和端口
server.bind(("localhost", 6666))
# 接收来自发送方的数据、地址
recv_data, address = server.recvfrom(1024)
print("你接收的数据：", recv_data.decode("utf-8"))
data = input("输入回复的数据：")
server.sendto(data.encode("utf-8"), address)
